package com.dev.security.manager.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.dev.security.config.dao.BaseRepository;
import com.dev.security.manager.beans.Source;

/**
 * @author 潜行的青衣
 * @see
 */
public interface SourceRepository extends BaseRepository<Source, String> {

	@Query("select s from Source s where per_id=?1")
	public Page<Source> findAll(String per_id, Pageable page);
	
	@Query("select s from Source s where per_id in ?1")
	public Page<Source> findAll(String[] per_ids, Pageable page);
	
	@Query("select count(s) from Source s where uri=?1")
	public long count(String uri);
	
	@Modifying
	@Query("delete from Source where uri in ?1 and per_id in ?2")
	public int delete(String[] uris, String[] per_ids);
	
	@Modifying
	@Query("delete from Source where per_id in ?1")
	public int deleteByPermission(String per_id);
}
